package com.sword.ttserver;

import java.util.Date;
import java.util.Map;

import com.sword.util.DateUtil;

public class TtserverTest {	
	
	//单机模式	服务器192.168.138.128
	//ttserver -host 192.168.138.128 -port 11211 -thnum 8 -dmn -pid /ttserver/ttserver.pid -log /ttserver/ttserver.log -le -ulog /ttserver/ -ulim 128m -sid 1 -rts /ttserver/ttserver.rts /ttserver/database.tch
		
		
	/*
	 //双机互为主辅模式 	  
	// ttservctl {start|stop|restart|hup}
	//服务器192.168.138.128
	 ttserver -host 192.168.138.128 -port 11211 -thnum 8 -dmn -pid /ttserver/ttserver.pid -log /ttserver/ttserver.log -le -ulog /ttserver/ -ulim 128m -sid 91 -mhost 192.168.138.129 -mport 11211 -rts /ttserver/ttserver.rts /ttserver/database.tch
	 
	//服务器192.168.138.129
	ttserver -host 192.168.138.129 -port 11211 -thnum 8 -dmn -pid /ttserver/ttserver.pid -log /ttserver/ttserver.log -le -ulog /ttserver/ -ulim 128m -sid 92 -mhost 192.168.138.128 -mport 11211 -rts /ttserver/ttserver.rts /ttserver/database.tch	
	*/	

	public static void main(String[] args) {
		Long begin=System.currentTimeMillis();		
		//存
//		TtserverTest.put();
		
		//取				
		TtserverTest.get();		

		//清空
//		TtserverTest.clear();
				
		Long end=System.currentTimeMillis();
		System.out.println(end-begin);
	}
	
	public static void put(){
		for(int i=0;i<100;i++){
			System.out.println(i);
			Memcached.put("key"+i, i,DateUtil.addDay(new Date(), 2));
			//Memcached.put("key"+i, i);
		}
	}
	
	public static void get(){
		for(int i=0;i<100;i++){
			System.out.println(Memcached.get("key"+i));
		}
	}
	
	public static void clear(){
		Memcached.flushAll();
	}
	
	
	public static void ergodic(){
		Map<?,?> map=Memcached.getStats();
		for(Object key:map.keySet()){
			System.out.println("key:" + key + " value:"+map.get(key));
		}
	}
	
}
